<template>
	<h2>单据参数设置</h2>
		<el-form-item :label="model[globalparam.documentDetailImportTemplate.paramCode].paramName">
			<template v-for="item in documentConfigs">
				<div style="float:left;margin-left: 20px;">
					<ex-label code="FamsDocumentConfig" :value="item.label"></ex-label>
					<ex-widget :model="model[globalparam.documentDetailImportTemplate.paramCode].paramValue" size="small" :column="{widgetType:'file',code:item.id,height:1}"></ex-widget>
				</div>
			</template>
		</el-form-item>
		<el-form-item :label="model[globalparam.documentPrintTemplate.paramCode].paramName">
			<template v-for="item in documentConfigs">
				<div style="float:left;margin-left: 20px;">
					<ex-label code="FamsDocumentConfig" :value="item.label"></ex-label>
					<ex-widget :model="model[globalparam.documentPrintTemplate.paramCode].paramValue" size="small" :column="{widgetType:'file',code:item.id,height:1}"></ex-widget>
				</div>
			</template>
		</el-form-item>
		<!--	 首页单据统计范围-->
		<el-form-item :label="model[globalparam.documentSummaryStatistics.paramCode].paramName">
			<ex-radio-group v-model="model[globalparam.documentSummaryStatistics.paramCode].paramValue" dict-code="DOCUMENT_STATISTICS_RANGE"></ex-radio-group>
		</el-form-item>
		<el-form-item :label="model[globalparam.documentSummaryState.paramCode].paramName">
			<ex-check-box v-model="model[globalparam.documentSummaryState.paramCode].paramValue" dict-code="DOCUMENT_STATUS"></ex-check-box>
		</el-form-item>
</template>

<script>

import globalparam from "@/constant/model/globalparam";
import ExRadioGroup from "@/components/exRadioGroup/index.vue";
import ExCheckBox from "@/components/exCheckBox/index.vue";
import ExWidget from "@/components/exFormItem/widget.vue";
import ExLabel from "@/components/exLabel/index.vue";

export default {
	name: 'documentSetting',
	computed: {
		globalparam() {
			return globalparam
		}
	},
	components: {ExLabel, ExWidget, ExCheckBox, ExRadioGroup},
	props: {
		model: {type: Object, default: {}}
	},
	data() {
		return {
			params: [
				globalparam.documentDetailImportTemplate,
				globalparam.documentPrintTemplate,
				globalparam.documentSummaryStatistics,
				globalparam.documentSummaryState,
			],
			documentConfigs:[],
		}
	},
	async created() {
		this.params.forEach(item => {
			if (!this.model[item.paramCode]) {
				this.model[item.paramCode] = item;
			}else{
				this.model[item.paramCode].paramName = item.paramName;
			}
		});
		let configs = await this.$cache.tree.reload('FamsDocumentConfig',{parentLevelCode:'0000000'});
		//console.log(configs);
		if(configs&&Array.isArray(configs)){
			configs.forEach(config=>{
				if(config.children){
					config.children.forEach(child=>{
						this.documentConfigs.push(child);
					});
				}else{
					this.documentConfigs.push(config);
				}
			});
		}
	},
	mounted() {
	},
	methods: {}
}
</script>
